<?php
include('connection/connection.php');
include('config.php');
//session_start();
//ob_start();
include('header.php');
include('menu.php');
$questionnaire=$_GET['questionnaire']; 
?>

<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<link href="css/style_question.css" type="text/css" rel="stylesheet" />
<title>Edit Questionnaires</title>
<SCRIPT language=JavaScript>
<!--
function reload(form)
{
var val=form.questionnaire.options[form.questionnaire.options.selectedIndex].value;
self.location='dd_questionnaire.php?questionnaire=' + val ;
}
function disableselect()
{
<?php
if(isset($questionnaire) and strlen($questionnaire) > 0){
echo "document.f1.questionnaire_page.disabled = false;";}
else{echo "document.f1.questionnaire_page.disabled = true;";}
?>
}
//-->
function gotoPage(pageName) {
//alert("Page Name "+ pageName);
if(pageName!=""){
	var formId = document.getElementById('formId').value;
	if(formId=="")
	{
		alert("Please enter form no. ");
		return false;
	}
document.f1.action="edit"+pageName+".php?formId="+formId;
document.f1.submit();
}
else {
	alert("Please select Page number");
}
}
</script>
</head>
<?php
$qryQuestionnaire="SELECT DISTINCT q_name,q_id FROM questionnaire order by q_name";
$recQuestionnaire=mysql_query($qryQuestionnaire); 
$q1="SELECT DISTINCT page_name,page_id,page_caption FROM page where q_id=$questionnaire order by page_name";
$q2="SELECT DISTINCT page_name,page_id,page_caption FROM page order by page_name";
if(isset($questionnaire) and strlen($questionnaire) > 0)
{
	$r1=mysql_query($q1); 
}
else
{
	$r1=mysql_query($q2); 
} 
?>
<body onload=disableselect();>
<div align="center">
<form method="post" name="f1" action='' onSubmit="return gotoPage(document.getElementById('questionnaire_page').value);">
<table border="0" width="746" id="table1" cellspacing="0" cellpadding="0">
<tr bgcolor="FF9966">
		<td height="29" align="left" valign="top" bgcolor="#FF9966" colspan="4">&nbsp;</td>
	</tr>
	<tr>
	<td bgcolor="#E5E5E5" align="center" colspan="4">
	<span lang="en-us">&nbsp;</span><span lang="en-us" style="font-size: 8.5pt"><font face="Verdana" color="#006699"><b>Edit Questionnaires</b></font></span></td>
</tr>
<tr><td bgcolor="#E5E5E5" align="left" colspan="4">&nbsp;</td>
</tr>
<tr><td align="left" colspan="4">&nbsp;</td>
</tr>
<tr><td width="29%" height="23"><font face="Verdana" style="font-size: 9pt" color="#000000">&nbsp;Select Questionnaire</font></td>
<td width="71%"><select name='questionnaire' onChange="reload(this.form)" class="txt">
<option value=''>Select one</option>
<?php
while($rowQuestionnaire = mysql_fetch_array($recQuestionnaire)) 
{ 
	if($rowQuestionnaire['q_id']==$questionnaire)
	{
	?>
		<option selected value=<?php echo $rowQuestionnaire['q_id'];?>><?php echo $rowQuestionnaire['q_name'];?></option><BR>
	<?php
	}
	else
	{
	?>
		<option value=<?php echo $rowQuestionnaire['q_id'];?>><?php echo $rowQuestionnaire['q_name'];?></option>
	<?php
	}
}
?>
</select></td></tr>
<tr><td height="26"><font face="Verdana" style="font-size: 9pt" color="#000000">&nbsp;Select Page No</font></td>
<td><select name='questionnaire_page' id='questionnaire_page' class="txt"><option value=''>Select one</option>
<?php
while($row = mysql_fetch_array($r1)) 
{ 
	echo  "<option value='$row[page_name]'>$row[page_caption]</option>";
}
?>
</select>
</td></tr>
<tr>
	<td height="26"><font face="Verdana" style="font-size: 9pt" color="#000000">&nbsp;Enter Form No</font></td>
	<td><input type="text" name="formId" id="formId" class="txt">&nbsp;&nbsp;<font face="Verdana" style="font-size: 8.5pt" color="#000000">*Enter Only Numeric Value Of Form-Id</font></td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
